package com.zone.infrastructure.persistent.po;

import com.zone.domain.acticity.model.entity.ActivityOrderEntity;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * @author: zongzi
 * @description: 抽奖活动
 * @date: 2024/6/23
 */
@Data
public class RaffleActivityOrder {
    /** 自增ID */
    private Long id;
    /** 用户ID */
    private String userId;
    /** 商品sku - 把每一个组合当做一个商品 */
    private Long sku;
    /** 活动ID */
    private Long activityId;
    /** 活动名称 */
    private String activityName;
    /** 抽奖策略ID */
    private Long strategyId;
    /** 订单ID */
    private String orderId;
    /** 下单时间 */
    private Date orderTime;
    /** 总次数 */
    private Integer totalCount;
    /** 日次数 */
    private Integer dayCount;
    /** 月次数 */
    private Integer monthCount;
    /** 订单状态（not_used、used、expire） */
    private String state;
    /** 业务仿重ID - 外部透传的，确保幂等 */
    private String outBusinessNo;
    /** 商品金额【积分】 */
    private BigDecimal productAmount;
    /** 创建时间 */
    private Date createTime;
    /** 更新时间 */
    private Date updateTime;

    public static ActivityOrderEntity convert2Entity(RaffleActivityOrder activityOrder) {
        if (Objects.isNull(activityOrder)) {
            return null;
        }
        ActivityOrderEntity activityOrderEntity = new ActivityOrderEntity();
        activityOrderEntity.setUserId(activityOrder.getUserId());
        activityOrderEntity.setSku(activityOrder.getSku());
        activityOrderEntity.setActivityId(activityOrder.getActivityId());
        activityOrderEntity.setActivityName(activityOrder.getActivityName());
        activityOrderEntity.setStrategyId(activityOrder.getStrategyId());
        activityOrderEntity.setOrderId(activityOrder.getOrderId());
        activityOrderEntity.setOrderTime(activityOrder.getOrderTime());
        activityOrderEntity.setTotalCount(activityOrder.getTotalCount());
        activityOrderEntity.setDayCount(activityOrder.getDayCount());
        activityOrderEntity.setMonthCount(activityOrder.getMonthCount());
        activityOrderEntity.setState(activityOrder.getState());
        activityOrderEntity.setOutBusinessNo(activityOrder.getOutBusinessNo());
        activityOrderEntity.setProductAmount(activityOrder.getProductAmount());
        return activityOrderEntity;
    }
}
